package aishua.com.mytestapplist.webkit;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.widget.Toast;

/**
 * Created by aishua on 2018/3/26.
 */

public class JsMessage {

    private JsMessage jsMessage;
    private Context context;

    public JsMessage(Context context) {

        this.context = context;
    }

//    public JsMessage Instance() {
//
//        if (jsMessage == null) {
//            synchronized (JsMessage.class) {
//
//                if (jsMessage == null) {
//                    jsMessage = new JsMessage();
//                }
//            }
//        }
//        return jsMessage;
//    }
    @JavascriptInterface
    public void showToast() {

        Toast.makeText(context, "军哥前来日狗", Toast.LENGTH_SHORT).show();
    }
    @JavascriptInterface
    public void showDialog() {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("联系人列表")
                .setItems(new String[]{"盖伦", "库奇", "寒冰", "塞恩"}, null)
                .setPositiveButton("确定", null)
                .create()
                .show();
    }
}
